home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Libraries / stdwin / Appls / klok / amsetdate.c next >
Encoding:
C/C++ Source or Header  |  1990-09-06  |  638 b   |  31 lines  |  [TEXT/????]

  1. /* Set the date and time -- Amoeba version */
  2.  
  3. #include <amtools.h>
  4. #include <module/tod.h>
  5. #include <ampolicy.h>
  6.  
  7. #include <time.h>
  8.  
  9. /* Set the date and time from a struct tm.
  10.    The input time is in local time.
  11.    If 'minchange' is zero, minutes and seconds are not taken
  12.    from the input but from the current system time. */
  13.  
  14. int
  15. setdatetime(tp, minchange)
  16.     struct tm *tp;
  17.     int minchange; /* nonzero if we must reset minutes and seconds, too */
  18. {
  19.     time_t new;
  20.     errstat err;
  21.     
  22.     new = mktime(tp);
  23.     if (!minchange)
  24.         new = new/3600*3600 + time((time_t *)0)%3600;
  25.     if (tod_settime(new, 0) != STD_OK) {
  26.         return -1;
  27.     }
  28.     else
  29.         return 0;
  30. }
  31.